#include<bits/stdc++.h>
using namespace std;
typedef long double db;
typedef tuple<int,int,int> tpi;
inline db sub_hypot(db x,db y){
  return sqrtl(x*x-y*y);
}
inline db f(tpi x,tpi y){
  int h1,d1,u1,h2,d2,u2;
  tie(h1,d1,u1)=x,tie(h2,d2,u2)=y;
  if(d2>=u1)return h1;
  db s1=hypotl(u1-d1,h1),s2=hypotl(u2-d2,h2);
  db k1=1.0*h1/(u1-d1),k2=1.0*h2/(u2-d2);
  if(d2>=d1&&k2>=k1)
    return sub_hypot(s1/(u1-d1)*(d2-d1),d2-d1);
  if(u2<=u1&&u2>=d1&&k2<=k1&&1.0*h1/(u1-d1)*(u2-d1)>=h2)
    return sub_hypot(s1/(u1-d1)*(u2-d1),u2-d1)-h2;
  if(d2<=d1){
    if(k2>=1.0*h1/(u1-d2))return 0;
    db x=k1*(d2-d1)/(k2-k1);
    if(hypotl(x,x*k2)>=s2)return 0;
  }
  return sub_hypot(s2/(u2-d2)*(u2-u1),u2-u1)+h1-h2;
}
int main(){
  freopen("wan.in","r",stdin);
  freopen("wan.out","w",stdout);
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int n; db c=0; cin>>n;
  vector<tpi> a(n);
  for(auto &i:a)cin>>get<0>(i)>>get<1>(i)>>get<2>(i);
  vector<db> h(n);
  for(int i=1;i<n;i++)
    for(int j=0;j<i;j++)
      h[i]=max(h[i],f(a[j],a[i])+h[j]);
  for(int i=0;i<n;i++)
    c=max(c,h[i]+get<0>(a[i]));
  cout<<fixed<<setprecision(9)<<c<<endl;
  return 0;
}